Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Nov 4, 2023

Reland of #47432

Also includes:

Fixes the performance on iOS by removing blocking on compilation of shaders. From local testing this has identical before/after numbers. Additional, ensures that we don't unecessarily specialize vertex shaders and notes this restriction in the documentation.


Adds support for Specialization constants to Impeller for our usage in the engine. A motivating example has been added in the impeller markdown docs.

Fixes flutter/flutter#136210
Fixes flutter/flutter#119357

ToMTLPixelFormat(desc.GetStencilPixelFormat());

return descriptor;
const auto& constants = desc.GetSpecializationConstants();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still a bit iffy, but we improve performance by not blocking on the specialization, it all goes into the same pipeline future which is only blocking once we actually trry to use it.

Since the compilation is out of process anyway, blocking on it is pointless and only serves to park the thread.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like we're writing javascript here with this chain of nested completion callbacks. ;) Looks safe to me, though.

promise->set_value(new_pipeline);
};
auto mtl_descriptor = GetMTLRenderPipelineDescriptor(descriptor);
#if FML_OS_IOS
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Todo: add back

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, i see this issue is closed. Is this intended to be removed now?

jonahwilliams added 2 commits November 4, 2023 04:14
@jonahwilliams jonahwilliams changed the title Add specialization support redux [Impeller] Add support for specialization constants redux. Nov 4, 2023
@jonahwilliams jonahwilliams marked this pull request as ready for review November 4, 2023 14:53
Copy link
Member

@bdero bdero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo latch question. Crasher fix & new changes make sense.

ToMTLPixelFormat(desc.GetStencilPixelFormat());

return descriptor;
const auto& constants = desc.GetSpecializationConstants();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like we're writing javascript here with this chain of nested completion callbacks. ;) Looks safe to me, though.

return descriptor;
// This latch is used to ensure that GetMTLFunctionSpecialized does not finish
// before the descriptor is completely set up.
auto latch = std::make_shared<fml::CountDownLatch>(1u);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing appears to be waiting on this latch, and I'm not sure why we'd need one. It looks like the descriptor is already done being set up by the time we call GetMTLFunctionSpecialized.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed. This was left over from an earlier iteration.

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 7, 2023
@auto-submit auto-submit bot merged commit be43db3 into flutter:main Nov 7, 2023
@jonahwilliams jonahwilliams added the revert Label used to revert changes in a closed and merged pull request. label Nov 7, 2023
@auto-submit auto-submit bot removed the revert Label used to revert changes in a closed and merged pull request. label Nov 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App e: impeller

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

[Impeller] Delay evaluation of ifdefs for GLES specific feature detection. [Impeller] support static shader variants using specialization constants

2 participants